package 基础语法.泛型;

import java.util.ArrayList;

public class 通配符 {
    public static void main(String[] args) {
        ArrayList<Ye> arrayList = new ArrayList<>();
        arrayList.add(new Ye());
        arrayList.add(new Fu());
        arrayList.add(new Zi());
        // show(arrayList);//不行，泛型得一致
        show(new ArrayList<Zi>());
        show_1(arrayList);
        show_1(new ArrayList<Fu>());

        show_2(new int[3]);
        show_2("Strubg");

        // show_3("");

        show_3(new Ye());
        show_3(new Zi());
        // show_4(new ArrayList<String>());
        show_4(new ArrayList<Zi>());
        /// new MyArrayList<String>();
        new MyArrayList<Zi>();


        show_5(new ArrayList<Fu>());

    }

    public static <E> void show(ArrayList<Zi> arrayList) {
    }

    public static <E> void show_1(ArrayList<E> arrayList) {
    }

    public static <E> void show_2(E e) {
    }

    public static <E extends Ye> void show_3(E e) {
    }// 限定E必须是Ye的子类

    public static void show_4(ArrayList<? extends Ye> e) {
    }// 限定参数必须是Ye的子类

        public static void show_5(ArrayList<? super Zi> e) {
    }// 限定参数必须是Zi的父类

    public static void show_6(Nothing<?  extends Ye> e){}//同样的

}

class Ye {
}

class Fu extends Ye {
}

class Zi extends Fu {
}

class Nothing<e>{}
class MyArrayList<E extends Ye> {// 限定必须是
}

class MyArrayList1<E extends Ye, K> {// E限定必须是
}
